using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.IO;
using Rapier.Kodachi.Shared;

namespace Rapier.Kodachi.WebSearch
{
    public class WebSearchEngine
    {
        private string _Name = String.Empty;
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        private string _QueryFormat = String.Empty;
        public string QueryFormat
        {
            get { return _QueryFormat; }
            set { _QueryFormat = value; }
        }

        public Bitmap GetImage(WebSearchPlugin webSearchPlugin)
        {
            byte[] imageBytes = webSearchPlugin.Host.DataManager.LoadBinaryData(webSearchPlugin, Name);
            if(imageBytes != null)
                return webSearchPlugin.Host.DataManager.ConvertObjectFromByteArray<Bitmap>(imageBytes);
            else
                return Rapier.Kodachi.WebSearch.Resource.Search;
        }

        public override bool Equals(object obj)
        {
            if (obj.GetType() != typeof(WebSearchEngine))
                return false;

            return _Name.Equals((obj as WebSearchEngine).Name);
        }

        public override int GetHashCode()
        {
            return _Name.GetHashCode();
        }

        public override string ToString()
        {
            return _Name;
        }
    }
}
